<template>
  <view>
    <view class="tab-bar">
      <view class="flex-1" v-for="(item, index) in tabs" :key="index">
        <view class="item" hover-class="u-hover" hover-stay-time="0" @click="change(item)">
          <image :src="`/static/tabs/${item.icon + (current === index ? '_fill' : '')}.png`" class="tab-icon"/>
          <view class="name" :style="{color: current === index ? '#1073FF' : ''}">{{ lang[item.name] }}</view>
        </view>
      </view>
    </view>
  </view>
</template>


<script lang="ts">
import Vue from 'vue';

export default Vue.extend({
  name: 'TabBar',
  props: {
    current: {
      type: Number,
      default: 0
    }
  },
  data() {
    return {
      tabs: [{
        path: '/pages/index/index',
        icon: 'home',
        name: 'home'
      },
        // {
        //   path: '/pages/Marketplace/Marketplace',
        //   icon: 'shop',
        //   name: 'shop'
        // },
        // {
        //   path: '/pages/Resources/Resources',
        //   icon: 'resource',
        //   name: 'resource'
        // },
        {
          path: '/pages/me/index',
          icon: 'me',
          name: 'me'
        }]
    };
  },
  computed: {
    lang(): any {
      return this.$t('tabBar');
    }
  },
  methods: {
    change(item: any) {
      uni.switchTab({url: item.path});
    }
  }
});
</script>

<style lang="scss" scoped>
.tab-bar {
  position: fixed;
  bottom: -200rpx;
  left: 0;
  right: 0;
  background: #ffffff;
  padding: 20rpx;
  font-size: 30upx;
  padding-bottom: calc(env(safe-area-inset-bottom) + 20rpx);
  z-index: 888;
  animation: example 1s;
  animation-fill-mode: forwards;
  animation-timing-function: cubic-bezier(0.18, 0.89, 0.32, 1.28);
  display: flex;
  align-content: center;
  @keyframes example {
    from {
      bottom: -200rpx;
    }
    to {
      bottom: 0;
    }
  }

  .flex-1 {
    flex: 1;
    -webkit-flex: 1;
    -webkit-box-flex: 1;
  }

  .item {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
  }

  .name {
    text-align: center;
    line-height: 24rpx;
    margin-top: 10rpx;
    font-size: $uni-font-size-sm;
    color: #D6DBDE;
  }

  .select {
    color: white;
  }

  .tab-icon {
    width: 54upx;
    height: 54upx;
  }
}
</style>